//*************************************************************************************************
//************************ (C) 2001 - 2006, Eleven Engineering Incorporated ***********************
//*************************************************************************************************
//**
//**		Tabs:	This file looks best with tab stops set every 6 spaces.
//**
//*************************************************************************************************
//*************************************************************************************************
//**
//**          File:  Thread2.asm
//**       Project:  EE400 Interfacing Project AD + LCD
//**       Created:  Nov 03 2008
//**       Revised:  Nov 13 2008
//**
//**   Description:  This file contains code for thread 2.  Thread 2 is responsible for
//**				 reading the output of the ADC when the appropriate flag is set
//**				 and outputting that value onto the LCD.
//** Compatibility:  Requires XInA v4.4 or higher.
//**
//**    Disclaimer:  You may incorporate this sample source code into your program(s) without
//**                 restriction.  This sample source code has been provided "AS IS" and the
//**                 responsibility for its operation is yours.  You are not permitted to
//**                 redistribute this sample source code as "Eleven sample source code" after
//**                 having made changes.  If you are going to re-distribute the source, we require
//**                 that you make it clear in the source that the code was descended from Eleven
//**                 sample source code, but that you have made changes.
//**
//*************************************************************************************************
//*************************************************************************************************

			mov   r7,T2_SP

			ld r0,0x0000 //init uses this

			jsr r6, InitializeLEDs
			ld r1,0x0001
Loop:
			jsr r6, ToggleLEDs
			jsr r6,DelayReallyLong
			jsr r6,DelayReallyLong		//waits so i can see
			jsr r6, ToggleLEDs    //flashes LEDs with a 1 in them
			mov r1,0x0002

						jsr r6, ToggleLEDs
			jsr r6,DelayReallyLong
			jsr r6,DelayReallyLong		//waits so i can see
			jsr r6, ToggleLEDs    //flashes LEDs with a 1 in them
			mov r1,0x0004
						jsr r6, ToggleLEDs
			jsr r6,DelayReallyLong
			jsr r6,DelayReallyLong		//waits so i can see
			jsr r6, ToggleLEDs    //flashes LEDs with a 1 in them
			mov r1,0x0008
						jsr r6, ToggleLEDs
			jsr r6,DelayReallyLong
			jsr r6,DelayReallyLong		//waits so i can see
			jsr r6, ToggleLEDs    //flashes LEDs with a 1 in them
			mov r1,0x0001
			bra Loop
NotDone:
			rol r1,r1,1
			bra Loop				//goes back to loop

			bra	@	// Prevent this thread from running away if it is accidentally enabled in the main file
